<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="UTF-8">
    </head>
    <body>
        <div id="progress"></div>
        <pre id="output">
        </pre>
        <script>
            var __total_done = 0;
            var __total_tests = 0;
            var __any_failures = false;
            __karma__ = {
                start: undefined,
                result: function(arg) {
                    __total_done++;
                    if (__total_done % 100 === 0 || __total_done === __total_tests) {
                        console.log("Finished running " + __total_done + '/' + __total_tests + " tests")
                    }
                    document.getElementById('progress').innerText = 'Progress: ' + __total_done + ' / ' + __total_tests;
                    if (!arg.success) {
                        var msg = "FAILED: " + arg.suite[0] + " " + arg.description;
                        console.error(msg);
                        __any_failures = true;
                        document.getElementById('output').innerText += "\n" + msg;
                    }
                    for (var i = 0; i < arg.log.length; i++) {
                        document.getElementById('output').innerText += "\n     " + arg.log[i];
                        console.log("    " + arg.log[i]);
                    }
                },
                info: function(arg) {
                    __total_tests = arg.total;
                    document.getElementById('progress').innerText = 'Progress: ' + __total_done + ' / ' + __total_tests;
                    document.getElementById('output').innerText += "\nTotal tests: " + arg.total + "\nRunning...";
                    console.log("Running " + arg.total + " tests...");
                },
                complete: function() {
                    var doneDiv = document.createElement('div');
                    doneDiv.id = 'done';
                    doneDiv.innerText = 'Done';
                    document.body.appendChild(doneDiv);
                }
            };

<!-- INCLUDE SOURCE PART -->

            document.getElementById('output').innerText = "Starting...";
            setTimeout(function() {
                __karma__.start();
            }, 0);
        </script>
    </body>
</html>
